#define _CRT_SECURE_NO_WARNINGS 1
#pragma once
#include<iostream>
using namespace std;

string BF(string s1, string s2)//s1:主串 s2:子串
{
	int len1 = s1.size();
	int len2 = s2.size();
	if (len2 > len1)  //子串比主串还长
		return "";

	int i = 0, j = 0;
	while (i < len1 && j < len2)
	{
		if (s1[i] == s2[j])
		{
			i++, j++; //i和j的步长一致
		}
		else
		{
			i = i - j + 1;//i来到主串的下一个位置开始匹配
			j = 0;//j = j -j 子串从头开始匹配
		}
	}
	if (j >= len2) //说明子串匹配完了
		return s1.substr(i - j);
	else
		return "";
}
int main()
{
	string s1;
	string s2;
	while (cin >> s1 >> s2)
	{
		cout << BF(s1, s2) << endl;
	}
	
	return 0;
}